package com.swizipuremvc.app.user.proxies
{
	import com.swizipuremvc.core.common.ProxyType;
	import com.swizipuremvc.app.user.proxies.interfaces.IDashboardProxy;
	import com.swizipuremvc.app.user.services.interfaces.IDashboardService;
	
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.Responder;
	import mx.rpc.events.FaultEvent;
	
	import org.puremvc.as3.multicore.patterns.proxy.Proxy;
	
	public class DashboardProxy extends Proxy implements IDashboardProxy
	{
		
		[Inject]
		public var dashboardService:IDashboardService;
		
		public function DashboardProxy()
		{
			super(ProxyType.DASHBOARD_PROXY.toString());
		}
		
		public function authenticateUser(user:String,password:String,result:Function):void
		{
			var token:AsyncToken = this.dashboardService.authenticateUser(user,password);
			token.addResponder(new Responder(result,onFault));
		}
		
		private function onFault(event:FaultEvent):void
		{
			Alert.show(event.fault.message,"Error");
		}	
	}
}